<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="socket.io.js"></script>
    <script src="jquery.min.js"></script>
</head>

<body>
    <div class="result">1</div>
    <div class="addOne">加1</div>
    <script>
        var socket = io.connect('http://localhost:3031');
        socket.on('message', function (data) {
            console.log(data);
        });
        var result = 0;
        $('.addOne').click(function () {
            result += 1;
            $('.result').html(result);
            socket.emit('num', {
                num: result
            })
        });
    </script>

</body>

</html>